<template>
  <div class="admin-container">
    <div class="admin-sidebar">
      <div class="user-info">
        <div class="user-avatar">
          <img src="@/assets/logo.png" alt="用户头像">
        </div>
        <div class="user-name">用户名</div>
        <el-dropdown trigger="click" class="user-dropdown">
          <span class="el-dropdown-link">
            <i class="el-icon-arrow-down"></i>
          </span>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item>修改个人信息</el-dropdown-item>
            <el-dropdown-item>退出登录</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
      <el-menu :default-active="$route.path" class="admin-menu" router>
        <el-menu-item index="index" ><i class="el-icon-share"></i>首页</el-menu-item>
        <el-submenu :key="m.name" v-for="m in menuList" :index="m.component">
          <template slot="title">
            <i class="el-icon-location"></i>
            <span>{{ m.name }}</span>
          </template>
          <el-menu-item v-for="c in m.children" :index="c.component" :key="c.component">{{ c.name }}</el-menu-item>
        </el-submenu>
      </el-menu>
    </div>
    <div class="admin-main">
      <router-view></router-view>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      menuList: [

        {name: "团队管理",
          component: "1",
          children: [
              {name: "员工管理", component: "user"},
              {name: "部门管理", component: "dept"},
              {name: "岗位管理", component: "post"},

          ]},
        {name: "系统管理",children: [
            {name: "角色管理", component: "role"},
            {name: "菜单管理", component: "menu"},
            {name: "通知公告", component: "notice"},
            {name: "操作日志", component: "operateLog"},
            {name: "登录日志", component: "loginInfo"},
          ], component: "2",},
        {name: "收费管理",children: [
            {name: "收费项管理", component: "page3"},
            {name: "业主管理", component: "page5"},
            {name: "租售合同管理", component: "page4"},
          ], component: "3",}
      ]
    };
  }
};
</script>

<style>
.admin-container {
  display: flex;
  height: 100vh;
}

.admin-sidebar {
  width: 200px;
  background-color: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.user-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  padding: 0 20px;
  background-color: #f2f2f2;
}

.user-avatar {
  width: 40px;
  height: 40px;
  overflow: hidden;
  border-radius: 50%;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-name {
  margin-left: 10px;
  font-size: 16px;
  font-weight: bold;
}

.user-dropdown {
  margin-left: 10px;
}

.admin-menu {
  padding-top: 10px;
}

.admin-main {
  flex: 1;
  padding: 20px;
}
</style>